home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / tvinp101.zip / TEST.PAS < prev    next >
Pascal/Delphi Source File  |  1992-05-13  |  2KB  |  83 lines

  1. program testinputs;
  2. { NOTE:  You must run Maketest.pas first to create the resource file that
  3.   is read by this program.
  4.  
  5.   This program demonstrates three key points of the Tinputs unit:
  6.   1.  Restoring TInputs from a stream
  7.   2.  Using the unit to get user input
  8.   3.  Retrieving that user input when needed.
  9.  
  10. }
  11.  
  12. uses objects,views,app,drivers,dialogs,tvinp101;
  13.  
  14. type Tmyapp = object(TApplication)
  15. end;
  16.  
  17. {
  18.   This data record reflects the dialog box contructed with the program
  19.   maketest.pas.  The elements of this record agree in type and insertion
  20.   order with the TInputs that were inserted into the dialog box by
  21.   maketest.  Failure to do so will cause unpredictable results.  See
  22.   TGroup.getdata() for more information.
  23.  }
  24.  
  25. inputdata = record
  26.   in_int : integer;
  27.   in_long : longint;
  28.   in_real : real;
  29.   in_double : double;
  30.   in_single : single;
  31.   in_extended : extended;
  32.   in_comp : comp;
  33. end;
  34.  
  35. var p : pdialog;
  36.     resource : TResourceFile;  { This is the resource created by maketest }
  37.     myapp : Tmyapp;
  38.     dialog_data : inputdata;
  39.  
  40.  
  41. begin
  42.   myapp.init;
  43.  
  44. { Don't forget to register those objects you wish to read
  45.   from the stream! }
  46.  
  47.   registerdialogs;
  48.   RegisterObjects;
  49.   RegisterViews;
  50.   RegisterNumerics;
  51.  
  52. { Open the resource }
  53.   resource.init(new(pbufstream,init('tinputs.res',stopen,1024)));
  54.  
  55. { Read the dialog box stored there }
  56.   p := pdialog(resource.get('Dialog'));
  57.  
  58. { Make sure we know what was previously in the data record }
  59.   fillchar(dialog_data,sizeof(dialog_data),0);
  60.  
  61. { Only retrieve data if the OK box was pressed }
  62.   if desktop^.execview(p) = cmOK then begin
  63.     p^.getdata(dialog_data);
  64.   end;
  65.  
  66. { Shut things down }
  67.   myapp.run;
  68.   myapp.done;
  69.  
  70. { And now display what we've got }
  71.   with dialog_data do begin
  72.     writeln('Last data entered: ');
  73.     writeln('Integer : ',in_int);
  74.     writeln('Longint : ',in_long);
  75.     writeln('Real    : ',in_real);
  76.     writeln('Single  : ',in_single);
  77.     writeln('Double  : ',in_double);
  78.     writeln('Extended: ',in_extended);
  79.     writeln('Comp    : ',in_comp);
  80.   end;
  81.   readln;
  82. end.
  83.